<template>
    <div class="con">
        <div class="title">
            <img src="../../assets/images/toutu5.png" alt class="toutu">
            <div class="info">
                <div class="content">
                    <p>还款账户</p>

                    <span>
                        <img :src="data.logoUrl" alt>
                        {{data.bankName}} ({{data.cardNo}})
                    </span>
                </div>
                <div class="content">
                    <p>还款日期</p>
                    <span>{{data.repayDate}}</span>
                </div>
                <div class="content">
                    <p>还款金额</p>
                    <span>{{data.repayAmount}}（{{data.repayCount}}笔）</span>
                </div>
                <div class="content">
                    <p>需预留额度</p>
                    <span>{{data.reserveAmount}}</span>
                </div>
                <div class="content">
                    <p>手续费</p>
                    <span>{{data.totalFee}}</span>
                </div>
            </div>
        </div>
        <div class="tip">
            <span @click="backplanlist()">
                查看还款计划明细
                <img src="../../assets/images/more2.png" alt>
            </span>
        </div>
        <img src="../../assets/images/tradedetail.png" alt style="width:100%">

        <div class="btn" @click="ok()">
            <button>确认并执行还款</button>
        </div>
    </div>
</template>

<script>
export default {
    name: "backplandetail",
    data() {
        return {
            timestamp: "",
            data: {}
        };
    },
    methods: {
        backplanlist() {
            this.$router.push({ name: "backplanlist" });
        },
        ok() {
            this.axios({
                method: "post",
                url: `${
                    this.siteUrl
                }/app/repay/confirmRepay?appid=web.2019&format=json&timestamp=${
                    this.timestamp
                }`,
                data: {
                    userId: localStorage.getItem("userId"),
                    repayOrderNo: this.data.repayOrderNo
                }
            })
                .then(response => {
                    console.log(response);
                    if (response.data.success == 1) {
                        if (response.data.data.unable == 0) {
                            this.$router.push({ name: "tradecheck",params:{data:response.data.data} });

                            this.$toast(response.data.message);
                        }else{
                            this.$toast("还款执行中");
                            this.$router.push({ name: "my"});



                        }
                    } else {
                        this.$toast(response.data.message);
                    }
                })
                .catch(error => {
                    console.log(error);
                    this.$toast("连接服务器异常");
                });
        }
    },
    mounted() {
        this.timestamp = Date.parse(new Date());
        this.data = JSON.parse(localStorage.getItem("backPlanDetail"));
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.con {
    width: 100%;
    min-height: 100vh;
    background: #fff;
}
.con .title {
    width: 100%;
    position: relative;
    color: #fff;
}
.con .title .toutu {
    width: 100%;
}
.info {
    width: 90%;
    margin-left: 5%;
    position: absolute;
    top: 0px;
    left: 0px;
}

.content {
    height: 38px;
    position: relative;
}
.content p {
    position: absolute;
    top: 21px;
    color: #fff6eb;
    height: 38px;
}
.content span {
    position: absolute;
    right: 0px;
    top: 21px;
}
.content span img {
    width: 18px;
    margin-right: 5px;
}
.tip {
    height: 50px;
    line-height: 60px;
    color: #ffae4e;
    text-align: center;
}
.tip span {
    margin: 0 auto;
    display: inline-block;
}
.tip img {
    width: 8px;
    vertical-align: 1px;
    margin-left: 2px;
}

.btn {
    width: 90%;
    height: 48px;
    line-height: 48px;
    background: #ffae4e;
    text-align: center;
    border-radius: 25px;
    box-shadow: 0px 10px 30px 0px #fbc27f;
    margin-left: 5%;
    margin-top: 44px;
}
.btn button {
    width: 100%;
    font-size: 17px;
    color: #fff;
    background: transparent;
}
</style>
